GraphRegexUtil

This util class provides helpful methods for finding fragment and query information in a GraphQL String. It has a method for finding all references to fragments. Another method for finding all defined fragments, which may exist after a query. And a method to test whether the current GraphQL String contains a query.

Author

eschlenz

Functions

Link copied to clipboard
fun containsAnOperation(graphqlContent: String): Boolean

Returns whether or not a valid GraphQL operation (query, mutation, or subscription) can be found in some GraphQL String.

Link copied to clipboard
fun findFragmentDefinitions(graphqlContent: String): Set<String>

Finds all defined fragments, which are usually found after a query. A set of all unique fragment names is returned.

Link copied to clipboard
fun findFragmentReferences(graphqlContent: String): Set<String>

Finds all distinct references to fragments in some GraphQL String. A set of all unique fragment names (which are the references) is returned.